<string xmlns="http://schemas.microsoft.co m/2003/10/Serialization/">{"Code": "InvalidRequest","Message":"Could not retrieve metrics."}</string>

I am trying to fetch metrices of cloud service using (Microsoft.WindowsAzure.Management) service api .I am able to get the definition of all metrices but while i am trying to retrieve the response for those metrices then getting error.The below is my code.

====================================================================================

X509Store store = new X509Store(

            StoreName.My, StoreLocation.CurrentUser);

 

            store.Open(OpenFlags.ReadOnly);

 

            string thumbprint = "--------------------------------";

 

            X509Certificate2 x509Certificate = store.Certificates.Find(

            X509FindType.FindByThumbprint, thumbprint, false)[0];

 

 

            string SUBSCRIPTION_ID = "-----------------------------------";

            CertificateCloudCredentials credentials =

            new CertificateCloudCredentials(SUBSCRIPTION_ID, x509Certificate);

 

            string cloudserviceResourceId = ResourceIdBuilder.BuildCloudServiceResourceId("wedsite", "-----------------------------", null, null);

 

            MetricsClient metricsClient = new MetricsClient(credentials);

 

           

            MetricDefinitionListResponse metricListResponse =

            metricsClient.MetricDefinitions.List(cloudserviceResourceId, null, null);

          

          

            foreach (MetricDefinition metricDefinition in

            metricListResponse.MetricDefinitionCollection.Value)

            {

                String displayName = metricDefinition.DisplayName;

                String metricName = metricDefinition.Name;

                TimeSpan alertableTimeWindows =

                metricDefinition.MinimumAlertableTimeWindow;

                String units = metricDefinition.Unit;

                String primaryAggregation = metricDefinition.PrimaryAggregation;

            }

           

            IList<string> lstdata = new List<string>();

            List<String> metricNames = new List<String>() { "Disk Read Bytes/sec",

            "Disk Write Bytes/sec", "Network In", "Network Out",

                "Percentage CPU" };                  

            MetricValueListResponse response = metricsClient.MetricValues.List(cloudserviceResourceId, metricNames, "",

                TimeSpan.FromMinutes(5), DateTime.UtcNow.AddDays(-1), DateTime.UtcNow);           

            foreach (MetricValueSet value in

            response.MetricValueSetCollection.Value)

            {

                String valueName = value.Name;

                foreach (MetricValue metricValue in value.MetricValues)

                {

                    Double? average = metricValue.Average;

                    Int32? count = metricValue.Count;

                    Double? maximum = metricValue.Maximum;

                    Double? minimum = metricValue.Minimum;

                    DateTime timestamp = metricValue.Timestamp;

                    Double? total = metricValue.Total;

                }

====================================================================================

Please reponse as soon as  possible.

Thanks

Avikash Sharma

September 18th, 2014 10:31am

Hi Avikash,

Sorry, it appears you have the wrong forum - this one is related to Azure Machine Learning. I'll shift this thread to the appropriate forum

Regards,

AK

Free Windows Admin Tool Kit Click here and download it now
September 18th, 2014 3:48pm

Can anyone answer the above. I am also facing the same issue.
January 6th, 2015 12:59pm

I've hit the same road block too. Did you ever find a solution to this? Any help would be greatly appreciated :)
Free Windows Admin Tool Kit Click here and download it now
August 18th, 2015 3:14am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics